#include <stdio.h>
#include "graph.h" // 请不要删除，否则检查不通过

bool matrix_insert_vertex(MatrixGraph *G, VertexType v){
    if(~matrix_locate_vertex(G, v) || G -> vexnum >= MAX_VERTEX_NUM) return false;
    G->vertex[G->vexnum++] = v;
    for(int i=0;i<G->vexnum;i++) G -> arcs[i][G -> vexnum - 1] = G -> arcs[G -> vexnum - 1][i] = 0;
    return true;
}

bool matrix_insert_arc(MatrixGraph *G, VertexType v, VertexType w){
    v = matrix_locate_vertex(G, v);
    w = matrix_locate_vertex(G, w);
    if(v == -1 || w == -1 || G -> arcs[v][w] == 1) return false;
    G -> arcs[v][w] = 1;
    if(G -> type == UDG) G -> arcs[w][v] = 1;
    G -> arcnum ++;
    return true;
}